#include <iostream>
using namespace std;

/**
 * 
 * 修理钟表
 * 
 */
int main() {
    int h, m, s, x, y, z;
    cin >> h >> m >> s >> x >> y >> z;
    h += x;
    m += y;
    s += z;

    m += s / 60;
    s %= 60;

    h += m / 60;
    m %= 60;

    h %= 24;

    cout << h << ' ' << m << ' ' << s << endl;
    return 0;
}